<template>
    <div>
        <!--资源添加页面-->
        <van-field label='手机号' placeholder="请输入手机号" v-model="form.mobile" @blur="mb"/>
        身份:<select name="" id="" v-model="form.role">
            <option :value="i.id" v-for="i in roleslist">{{i.name}}</option>
        </select>
        <br>

        <van-button @click="login">登录</van-button>

    </div>
</template>

<script>
    export default {
        data() {
            return {
                form:{},
                roleslist:[]
            }
        },
        methods: {
            //验证手机号是否合法
            mb(){
                //判断手机号是否符合标准
                let res = /^1[3-9][0-9]{9}$/
                if(!res.test(this.form.mobile)){
                    this.$toast.success('手机号不合法')
                    
                }
            },
            //登录
            login(){
                this.$axios.post('/user/loginM/',this.form).then(res=>{
                    
                })
            },
             //获取角色
            getroles(){
                this.$axios.get('/user/rolesadd/').then(res=>{
                    this.roleslist = res.data.list
                    
                })
            },
        },
        mounted() {
            this.getroles()
        },
        
    }
</script>

<style scoped>

</style>